

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>横向自动下拉菜单</title>
<style>
  .menu {
    display: flex;
  }

  .menu-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    background-color: #f0f0f0;
    color: #333;
    margin-right: 10px; /* Space between menu items */
  }

  .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #fff;
    padding: 10px;
    box-shadow: 0px 2px 5px rgba(121, 122, 123, 0.292);
    z-index: 1; /* Ensure submenu is above other content */
  }

  .menu-item:hover .submenu {
    display: flex;
    flex-direction: column;
  }

  /* Optional: Add a triangle to indicate dropdown */
  .menu-item::after {
    content: "\25BC"; /* Unicode character for down arrow */
    margin-left: 5px;
  }
</style>
</head>
<body>

<div class="menu">
  <div class="menu-item">
    菜单项 1
    <div class="submenu">
      <div>a</div>
      <div>b</div>
      <div>c</div>
    </div>
  </div>
  <div class="menu-item">
    菜单项 2
    <div class="submenu">
      <div>a</div>
      <div>b</div>
    </div>
  </div>
  <div class="menu-item">
    菜单项 3
    <div class="submenu">
      <div>a</div>
    </div>
  </div>
</div>

</body>
</html>
